//
//  YCLifeServiceViewController.m
//  YCSchool
//
//  Created by gmall on 16/5/6.
//  Copyright © 2016年 yanglinxia. All rights reserved.
//  生活服务

#import "YCLifeServiceViewController.h"
#import "YCLifeServiceDetailViewController.h"

@interface YCLifeServiceViewController ()<UITableViewDelegate,UITableViewDataSource>

/** tableView */
@property (nonatomic, strong) UITableView *tableView;
/** 数据  */
@property (nonatomic, strong) NSArray *dataArray;

@end

@implementation YCLifeServiceViewController


- (NSArray *)dataArray
{
    if (!_dataArray) {
        _dataArray = @[
                       @"一乘特色小吃",
                       @"一乘特日新达超市",
                       @"一乘驾校医务室",
                       ];
    }
    return _dataArray;
}


- (UITableView *)tableView
{
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, self.view.yc_width, self.view.yc_height-64) style:UITableViewStylePlain];
        //        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        _tableView.dataSource = self;
        _tableView.delegate = self;
        //        _tableView.backgroundColor = [UIColor yc_colorWithUInt:0xf7f7f7];
    }
    return _tableView;
}

#pragma mark - 生命周期

- (void)viewDidLoad {
    [super viewDidLoad];
    [self yc_addBackBarButtonItem];
    self.navigationItem.title = @"生活服务";
    [self.view addSubview:self.tableView];
    
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


#pragma mark - UITableViewDataSource

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    return self.dataArray.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"lifeServiceCell"];
    if (!cell) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"lifeServiceCell"];
        cell.textLabel.font = [UIFont systemFontOfSize:14];
        cell.textColor = [UIColor yc_colorWithUInt:0x333333];
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }
    cell.textLabel.text = self.dataArray[indexPath.row];
    return cell;
}

#pragma mark - UITableViewDelegate

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    YCLogFunc
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    YCLifeServiceDetailViewController *carDetailVc = [[YCLifeServiceDetailViewController alloc] initWithTitleName:self.dataArray[indexPath.row]];
    [self.navigationController pushViewController:carDetailVc animated:YES];
}



@end
